/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Sik
 */
@Entity
@Table(name = "competition")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "Competition.findAll", query = "SELECT c FROM Competition c"),
    @NamedQuery(name = "Competition.findByIdCompetition", query = "SELECT c FROM Competition c WHERE c.idCompetition = :idCompetition"),
    @NamedQuery(name = "Competition.findByDate", query = "SELECT c FROM Competition c WHERE c.date = :date"),
    @NamedQuery(name = "Competition.findByAdversaire", query = "SELECT c FROM Competition c WHERE c.adversaire = :adversaire"),
    @NamedQuery(name = "Competition.findByScoreDomicile", query = "SELECT c FROM Competition c WHERE c.scoreDomicile = :scoreDomicile"),
    @NamedQuery(name = "Competition.findByScoreExterieur", query = "SELECT c FROM Competition c WHERE c.scoreExterieur = :scoreExterieur"),
    @NamedQuery(name = "Competition.findByResultat", query = "SELECT c FROM Competition c WHERE c.resultat = :resultat"),
    @NamedQuery(name = "Competition.findByType", query = "SELECT c FROM Competition c WHERE c.type = :type")
})
public class Competition implements Serializable
{
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idCompetition")
    private Integer idCompetition;
    @Column(name = "date")
    @Temporal(TemporalType.DATE)
    private Date date;
    @Column(name = "adversaire")
    private String adversaire;
    @Column(name = "scoreDomicile")
    private Integer scoreDomicile;
    @Column(name = "scoreExterieur")
    private Integer scoreExterieur;
    @Column(name = "resultat")
    private String resultat;
    @Column(name = "type")
    private String type;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "competition")
    private List<Disponibilite> disponibiliteList;
    @OneToMany(mappedBy = "competitionidCompetition")
    private List<Deplacement> deplacementList;
    @JoinColumn(name = "saison_idSaison", referencedColumnName = "idSaison")
    @ManyToOne(optional = false)
    private Saison saisonidSaison;
    @JoinColumn(name = "equipe_idEquipe", referencedColumnName = "idEquipe")
    @ManyToOne(optional = false)
    private Equipe equipeidEquipe;

    public Competition()
    {
    }

    public Competition(Integer idCompetition)
    {
        this.idCompetition = idCompetition;
    }

    public Integer getIdCompetition()
    {
        return idCompetition;
    }

    public void setIdCompetition(Integer idCompetition)
    {
        this.idCompetition = idCompetition;
    }

    public Date getDate()
    {
        return date;
    }

    public void setDate(Date date)
    {
        this.date = date;
    }

    public String getAdversaire()
    {
        return adversaire;
    }

    public void setAdversaire(String adversaire)
    {
        this.adversaire = adversaire;
    }

    public Integer getScoreDomicile()
    {
        return scoreDomicile;
    }

    public void setScoreDomicile(Integer scoreDomicile)
    {
        this.scoreDomicile = scoreDomicile;
    }

    public Integer getScoreExterieur()
    {
        return scoreExterieur;
    }

    public void setScoreExterieur(Integer scoreExterieur)
    {
        this.scoreExterieur = scoreExterieur;
    }

    public String getResultat()
    {
        return resultat;
    }

    public void setResultat(String resultat)
    {
        this.resultat = resultat;
    }

    public String getType()
    {
        return type;
    }

    public void setType(String type)
    {
        this.type = type;
    }

    @XmlTransient
    public List<Disponibilite> getDisponibiliteList()
    {
        return disponibiliteList;
    }

    public void setDisponibiliteList(List<Disponibilite> disponibiliteList)
    {
        this.disponibiliteList = disponibiliteList;
    }

    @XmlTransient
    public List<Deplacement> getDeplacementList()
    {
        return deplacementList;
    }

    public void setDeplacementList(List<Deplacement> deplacementList)
    {
        this.deplacementList = deplacementList;
    }

    public Saison getSaisonidSaison()
    {
        return saisonidSaison;
    }

    public void setSaisonidSaison(Saison saisonidSaison)
    {
        this.saisonidSaison = saisonidSaison;
    }

    public Equipe getEquipeidEquipe()
    {
        return equipeidEquipe;
    }

    public void setEquipeidEquipe(Equipe equipeidEquipe)
    {
        this.equipeidEquipe = equipeidEquipe;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (idCompetition != null ? idCompetition.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Competition))
        {
            return false;
        }
        Competition other = (Competition) object;
        if ((this.idCompetition == null && other.idCompetition != null) || (this.idCompetition != null && !this.idCompetition.equals(other.idCompetition)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "Model.Competition[ idCompetition=" + idCompetition + " ]";
    }
    
}
